package com.qualcomm.vuforia.CloudRecognition.implement;

import javax.servlet.Filter;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.FilterChain;
import javax.servlet.http.HttpServletRequest;

import java.io.IOException;

public class MyFilter implements Filter{
	
	public void init(FilterConfig filterConfig) throws ServletException {}
	
	public void destroy() {}
	
	public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, 
			FilterChain filterChain) throws IOException, ServletException {
		
		if (servletRequest instanceof HttpServletRequest) {
			HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
			
			FakeHttpServletRequest fake = new FakeHttpServletRequest(httpServletRequest);
			filterChain.doFilter(fake, servletResponse);
		} else filterChain.doFilter(servletRequest, servletResponse);
		 
		return;
	}

}
